//https://www.luogu.com.cn/problem/P5788
//单调栈
#include<stack>
#include<vector>
#include<iostream>
#include<utility>
// 定义函数 f(i)f(i) 代表数列中第 i 个元素之后第一个大于 a_i  的元素的下标，
// 即 f(i)=min_{i<j<= n, a_j > a_i} {j}。
// 若不存在，则 f(i)=-1。
template<typename _iterator>
std::vector<int> min_greater_pos(_iterator _begin,_iterator _end){
	std::vector<int>res;
	res.resize(_end-_begin);
	std::stack<std::pair<typename _iterator::value_type,int>> monotone_stack;
	auto i=_begin;
	for(;i!=_end;++i){
		int delta=i-_begin;
		while(!monotone_stack.empty()&& *i>monotone_stack.top().first){
			std::pair<typename _iterator::value_type,int>& Top=monotone_stack.top();
			res[Top.second]=i-_begin;
			monotone_stack.pop();
		}
		monotone_stack.push(std::pair<typename _iterator::value_type,int>(*i,i-_begin));
	}
	while(!monotone_stack.empty()){
			res[monotone_stack.top().second]=-1;
			monotone_stack.pop();
	}
	return res;

}


int main(){
	using namespace std;
	int num,temp;
	vector<int> v;
	cin>>num;
	v.resize(num);
	for(int i=0;i<num;++i){
		cin>>v[i];
	}
	vector<int>::iterator it;
	auto mgp=min_greater_pos(v.begin(),v.end());
	for(int i:mgp){cout<<i+1<<" ";}
	return 0;
}